import array
import gc
import time
import cStringIO
import os
import collections
import math



def measure(runner, *args):
	gc.collect()
	elapsed = -1
	try:
		start = time.time()
		runner(*args)
		stop = time.time()
		elapsed = stop - start
	except Exception, e:
		print e
	return elapsed


def rotateString(data, loops):
	antiomit = None
	for i in xrange(loops):
		data = data[1:] + data[0]

def testString():
	count = 2 ** 32
	for i in xrange(10, 20):
		length = 2 ** i
		loops = count // length
		data = os.urandom(length)
		time = measure(rotateString, data, loops)
		print "%07d, %07d, %07.3f, %07.3f" % (length, loops, time, 1000*time/loops)

def main():
	testString()

if __name__ == '__main__':
	main()
